package alipay.openplatform.edu.campus.jiuye.common.enums;

/**
 * Created by xuankang on 16/9/18.
 */
public enum TopicInfoStateEnum {

    START(0,"未开始"),
    END(1,"已过期"),
    DELETE(2,"已删除");
    private  int code;
    private  String Message;
    TopicInfoStateEnum(int code, String message){
        this.code = code;
        this.Message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return Message;
    }

    public void setMessage(String Message) {
        this.Message = Message;
    }
    /**
     * 根据名称得到码
     *
     * @param name
     * @return
     */
    public static Integer getCode(String name) {
        if (name == null || "".equals(name)) {
            return -1;
        }
        for (TopicInfoStateEnum enumType : TopicInfoStateEnum.values()) {
            if (name != null && name.equals(enumType.getMessage())) {
                return enumType.getCode();
            }
        }
        return -1;
    }

    /**
     * 根据码得到名称
     *
     * @param code
     * @return
     */
    public static String getMessage(Integer code) {
        if (code == null) {
            return null;
        }
        for (TopicInfoStateEnum enumType : TopicInfoStateEnum.values()) {
            if (code == enumType.getCode()) {
                return enumType.getMessage();
            }
        }
        return null;
    }
}
